<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 自己封装一个函数
        var mymath = {
            PI: 3.1415926,
            max: function () {
                var max = arguments[0];
                for (var i = 1; i < arguments.length; i++) {
                    if (arguments[i] > max) {
                        max = arguments[i]
                    }
                }
                return max;
            },
            min: function () {
                var min = arguments[0];
                for (var i = 1; i < arguments.length; i++) {
                    if (arguments[i] < min) {
                        min = arguments[i]
                    }
                }
                return min;
            }
        }
        console.log(mymath.PI);
        console.log(mymath.max(1, 5, 9));
        console.log(mymath.min(1, 5, 9));
    </script>


    <!-- //随机数 -->
    <script>
        //Math.Random 返回一个小数 [0,1)
        var random = (Math.random() * 2).toFixed(2);
        console.log(random);

        //得到一个整数 0-9
        var random1 = Math.floor(Math.random() * 10);
        console.log(random1);


        //得到一个区间的数 包括这两个数值(math.random()*(max-min+1))+min
        function getRandom(min, max) {
            return Math.floor(Math.random() * (max - min + 1))  + min;

        }
        console.log(getRandom(0, 10));
    </script>


    <script>
        var arr = ['张可顺', '李金周', '发展哥', '梦泪', '孟磊', '涛涛兄'];

        function getRandom(min, max) {
            return Math.floor(Math.random() * (max - min + 1) + min);
        }
        var str = arr[getRandom(0, arr.length - 1)];
        console.log(str);
    </script>


    <!-- 猜数字 -->
    <!-- <script>
        function getRandom(min, max) {
            return Math.floor(Math.random() * (max - min + 1) + min);
        }
        var value = getRandom(1, 10);
        while (true) {
            var num = prompt("请输入您猜的数字");
            if (num == value) {
                console.log('恭喜你猜对了');
                break;
            } else if (num > value) {
                console.log('你的数字猜的大了');
            } else {
                console.log('你猜的数小了');

            }
        }
    </script> -->
</head>

<body>

</body>

</html>